<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../frame/layui/css/layui.css">
    <link rel="stylesheet" href="../../frame/static/css/style.css">
    <link rel="stylesheet" href="../../css/common.css">
    <link rel="stylesheet" href="../../css/currency/index.css">
  	<style>
      .currencyBox{
      		width:100%  ;
            height:210px  	
      }
      .currency{
      	float:left;
      
      } 	
    </style>  
</head>
<body class="body">
<div class="my-btn-box">
    <span class="fl">
        <a class="layui-btn btn-add btn-default" id="btn-add">添加</a>
        <a class="layui-btn btn-add btn-default" id="btn-refresh" onclick="location.reload()">
            <i class="layui-icon">&#x1002;</i></a>
    </span>
</div>
<div class="layui-card">
    <div class="layui-card">
        <div class="layui-card-body">
            <img src="../../img/loading.gif">
        </div>
    </div>
</div>
<script src="../../js/public/jquery-3.1.1.min.js"></script>
<script src="../../js/layer/layer.js"></script>
<script src="../../js/public/common.js"></script>
<script>
  	$(function(){
    list();

    //todo 展示下拉
    $('.layui-colla-title').click(function(){
        let result = $(this).attr('show');
        if(result == 1){
            let ref = $(this).next();
            ref.addClass('layui-show');
            $(this).attr('show',2);
        }else{
            $(this).next('.layui-colla-content').removeClass('layui-show');
            $(this).attr('show',1);
        }
    });

    //todo 添加
    $('#btn-add').click(function(){

        layOpen('添加币种','500px','400px','create.html')
    });

    $('.layui-colla-item span').click(function(){
        let cu_id = $(this).attr('ids');
        layOpen('编辑','500px','400px','edit.html?cu_id='+cu_id)
    })
});


function list(){
    let data = AjaxForm('admin/CurrencyList');
    let html ='';
    let show = '<h2 class="layui-colla-title show" show="1">';
    for (let i=0;i<data.length;i++){
        if(data[i].show === 2){
            show = '<h2 class="layui-colla-title noshow" show="1">'
        }
        let ref = data[i].son;
        let son = '';
        for (let f=0;f<ref.length;f++){
            let icon = '';
            let sonshow = `<span class="show currency" ids="${ref[f].cu_id}">`;
            if(ref[f].show === 2)sonshow = `<span class="noshow currency" ids="${ref[f].cu_id}">`;
            if(ref[f].type === 1)icon = '<icon class="layui-badge-dot"></icon>';
            son += `${sonshow}${ref[f].title}/USDT${icon}</span>`
        }
        html += `<div class="layui-colla-item">
                   ${show}${data[i].title}<i class="layui-icon layui-colla-icon"></i></h2>
                    <div class="layui-colla-content">
                      	<p class="currencyBox">${son}</p>
                    </div>
                </div>`
    }
    $('.layui-card-body').html(html);

    $('.del').click(function(){
        let cu_id = $(this).attr('ids');
        layFirm('删除','admin/CurrencyDel',{cu_id:cu_id});
    })
}
  
</script>
</body>
</html>